/**
 * @param {number[][]} matrix
 * @return {void} Do not return anything, modify matrix in-place instead.
 */
var rotate = function (matrix) {
  let xlen = matrix.length;
  let ylen = matrix[0].length;
  let tempArr = new Array(xlen);
  for (let i = 0; i < tempArr.length; i++) {
    tempArr[i] = new Array(ylen);
  }
  for (let i = 0; i < xlen; i++) {
    for (let j = 0; j < ylen; j++) {
      tempArr[j][xlen - i - 1] = matrix[i][j];
    }
  }
  for (let i = 0; i < xlen; i++) {
    for (let j = 0; j < ylen; j++) {
      matrix[i][j] = tempArr[i][j];
    }
  }
};
